<?php
class IndexAction extends CommonAction
{
    public function _initialize()
    {
        parent::_initialize();
        $this->assign('nav', 1);
        $this->assign('web_title', '系统首页');
    }

    public function index()
    {
        $this->userStatistics();
        $this->getTaskSituation();
        $this->display();
    }

    /**
     * 根据登录者获取对应统计
     * @author ice<iceinto@mallog.com.cn>
     */
    public function userStatistics()
    {
        $role = $this->_role['role_id'];
        $Date = new Date();
        $fireTime = $Date->firstDayOfMonth()->format("%Y-%m-%d");
        $lastTime = $Date->lastDayOfMonth()->format("%Y-%m-%d");

        $fireTime = strtotime($fireTime);
        $lastTime = strtotime($lastTime);

        $map['create_time'] = array(array('egt', $fireTime), array('elt', $lastTime));
        $map['uid'] = $this->getLoginUserInfo();
        //判断用户类型
        if ($role == 2) {
            //审核 2  统计审核数量
            $taskAuditCount = M('TaskAudit')->where($map)->count();
            $this->assign('taskAuditCount', $taskAuditCount);
        } else if ($role == 3) {
            //维护美工 3 接小图任务数量 接维护任务数量
            $taskCount = M('TaskAllot')->where($map)->count();
            $this->assign('taskCount', $taskCount);
            unset($map['create_time']);
            $map['add_time'] = array(array('egt', $fireTime), array('elt', $lastTime));
            $mCount = M('MaintenanceAllot')->where($map)->count();
            $this->assign('mCount', $mCount);
        } else if ($role == 5) {
            //编辑 5 统计添加小活动数量 添加维护数量 添加电话号码
            $taskCount = M('Task')->where($map)->count();
            $this->assign('taskCount', $taskCount);
            unset($map['create_time']);
            $map['add_time'] = array(array('egt', $fireTime), array('elt', $lastTime));
            $mCount = M('Maintenance')->where($map)->count();
            $this->assign('mCount', $mCount);
            unset($map['uid']);
            $map['editor'] = $this->getLoginUserInfo();
            $phoneCount = M('MallPhone')->where($map)->count();
            $this->assign('phoneCount', $phoneCount);
        }
    }
}

?>